
#ifndef __NEW_H__
#define __NEW_H__

#include <stdlib.h>
#include <malloc/malloc.h>
#include <memory.h>

void* operator new( size_t, void* _where );
void operator delete( void*, void* );

inline void* operator new( size_t, void* _where ) { return (_where); }
inline void operator delete( void*, void* ) {}
inline void* operator new(size_t size)
{
	void* p = malloc(size);
	memset(p,0,size);
	return p;
}

		#define MALLOC					   malloc
		#define FREE					   free
		
		#define CREATEOBJ(size)            MALLOC((size))
		#define FREEOBJ(ptr)               FREE((ptr))
		#define MALLOCREC(type)            ((type *)MALLOC(sizeof(type)))
		#define MALLOCREC_EX(type,cbExtra) ((type *)MALLOC(sizeof(type) + (cbExtra)))
		#define FREEIF(p)                  if (p) { FREE((void *)p); p = 0; }
		
		// macros to enable memory tracking (compiled out)
		#define DMALLOC(size)                  MALLOC(size)
		#define DMALLOCREC(type)               MALLOCREC(type)
		#define DMALLOCREC_EX(type,addsize)    MALLOCREC_EX(type,addsize)
		#define DFREE(ptr)                     FREE(ptr)

		#define DNEW                           new
		#define DDELETE(object)                delete (object)
		#define DNEWARR(t,s)                   new t[(s)] 
		#define DDELETEARR(object)             delete[] (object)

		#define DFREETRACKINGENTRY(ptr)			
		#define DMEMREPORT()	
		#define DMEMTRACKFINI() 
		
#endif //#ifndef __NEW_H__
